From 4d60b5b10c472fb3b37465cede661288708e16e6 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 8 Jan 2016 13:44:36 -0500 Subject: [PATCH] x11: Fix damage tracking hack We are setting mime data with a destroy notify on the cairo surface to get notified when cairo registers damage for the surface (in that case, it clears the mime data, calling the destroy notify). Unfortunately, the destroy notify is also called when we remove the mime data ourselves, which was not intentional. Use a flag in the window impl struct to ignore the callback when we are clearing the hook. --- gdk/x11/gdkwindow-x11.c | 30 +++++++++++++++++++----------- gdk/x11/gdkwindow-x11.h | 1 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/gdk/x11/gdkwindow-x11.c b/gdk/x11/gdkwindow-x11.c index 9f189ad626..6106b28d18 100644 --- a/gdk/x11/gdkwindow-x11.c +++ b/gdk/x11/gdkwindow-x11.c @@ -250,8 +250,10 @@ static void on_surface_changed (void *data) { GdkWindow *window = data; + GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); - window_pre_damage (window); + if (impl->tracking_damage) + window_pre_damage (window); } /* We want to know when cairo drawing causes damage to the window, @@ -269,12 +271,15 @@ hook_surface_changed (GdkWindow *window) GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); if (impl->cairo_surface) - cairo_surface_set_mime_data (impl->cairo_surface, - "x-gdk/change-notify", - (unsigned char *)"X", - 1, - on_surface_changed, - window); + { + cairo_surface_set_mime_data (impl->cairo_surface, + "x-gdk/change-notify", + (unsigned char *)"X", + 1, + on_surface_changed, + window); + impl->tracking_damage = 1; + } } static void @@ -283,10 +288,13 @@ unhook_surface_changed (GdkWindow *window) GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl); if (impl->cairo_surface) - cairo_surface_set_mime_data (impl->cairo_surface, - "x-gdk/change-notify", - NULL, 0, - NULL, NULL); + { + impl->tracking_damage = 0; + cairo_surface_set_mime_data (impl->cairo_surface, + "x-gdk/change-notify", + NULL, 0, + NULL, NULL); + } } static void diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index 2bc2417d8b..ed0cbb6cf3 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -73,6 +73,7 @@ struct _GdkWindowImplX11 guint override_redirect : 1; guint frame_clock_connected : 1; guint frame_sync_enabled : 1; + guint tracking_damage: 1; gint window_scale; -- 2.30.2